﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

/// <summary>
/// Summary description for Palestra
/// </summary>
public partial class Palestra
{
    public static List<Palestra> findByEvento(Guid idEvento)
    {
        DataClassesDataContext dc = new DataClassesDataContext();
        return dc.Palestras.Where(p => p.idEvento.Equals(idEvento)).ToList();
    }
    public static bool createPalestra(Palestra palestra)
    {
        try
        {
            DataClassesDataContext dc = new DataClassesDataContext();
            dc.Palestras.InsertOnSubmit(palestra);
            dc.SubmitChanges();
            return true;
        }
        catch (Exception e)
        {
            return false;
        }
    }
    public static Palestra findPalestra(Guid idPalestra)
    {
        DataClassesDataContext dc = new DataClassesDataContext();
        return dc.Palestras.Single(p => p.id.Equals(idPalestra));
    }
    public static bool excludePalestra(Guid idPalestra)
    {
        try
        {
            DataClassesDataContext dc = new DataClassesDataContext();
            Palestra palestra = dc.Palestras.Single(p => p.id.Equals(idPalestra));
            dc.Palestras.DeleteOnSubmit(palestra);
            dc.SubmitChanges();
            return true;
        }
        catch (Exception ex)
        {
            return false;
        }
    }
    public static bool changePalestra(Guid idPalestra, DateTime data, string horario, string titulo, string descricao, Guid idUsuario, string local)
    {
        try
        {
            DataClassesDataContext dc = new DataClassesDataContext();
            Palestra palestra = dc.Palestras.Single(p => p.id.Equals(idPalestra));
            palestra.data = data;
            palestra.descricao = descricao;
            palestra.horario = horario;
            palestra.idUsuario = idUsuario;
            palestra.local = local;
            palestra.titulo = titulo;
            dc.SubmitChanges();
            return true;
        }
        catch (Exception ex)
        {
            return false;
        }
    }
}